06. Promises with .forEach

Promises with .forEach

Promises with .forEach Quiz

Instructions

First, if you haven't already, read this and follow the instructions on working with the Exoplanet Explorer repo.

  1. Checkout the foreach-start branch and navigate to app/scripts/app.js.
  2. Refactor .forEach to create a sequence of Promises that always resolves in the same order it was created.
    • Fetch each planet's JSON from the array of URLs in the search results.
    • Call createPlanetThumb(data) on each planet's response data to add it to the page.
  3. Use developer tools to determine if the planets are being fetched in series or in parallel.

There's a typo in the loop that shows up around 1:10! It should look like this:

var x = 0;
for (var i = 0; i < 10; i++) {
    x = x + 1;
}

Checkout the foreach-solution branch to see my code!

How are the requests executed? Check the network panel.

SOLUTION: Series

2.6 Promises with .forEach Solution